RUNDLL FAQ


This FAQ describes how to run Control Panel (and other) tools in Windows from MMB script.

Rundll32.exe is used by Windows to launch actions defined in DLLs. One of its capabilities is running Control Panel tools (applets).
Using Rundll32.exe, you can launch the applets from a CPL file, and you can cause the applet to open on a particular page.

Basic Script Syntax:
Run("rundll32.exe","shell32.dll,Control_RunDLL filename.cpl")

General syntax:
Run("rundll32.exe","shell32.dll,Control_RunDLL filename.cpl,@n,t")
where filename.cpl is the name of one of Control Panel's *.CPL files, n is the zero based number of the applet within the *.CPL file, and t is the number of the tab for multi paged applets.

To select a particular applet within the file, append a comma, an @ sign, and the number of the applet.
Launch the keyboard applet, which is the second applet within Main.cpl, you would use:
Run(" rundll32.exe","shell32.dll,Control_RunDLL main.cpl,@1")

Some multipage applets are designed so that they can be opened at a particular page. You must specify the applet number (@0 for a single-applet file). Then append a comma and the page number.
This line launches the Display Properties dialog and opens to the Appearance page (the third page; number two ):
Run("rundll32.exe","shell32.dll,Control_RunDLL desk.cpl,@0,2")

Control panel tools and applets:

Accessibility Options access.cpl
Add New Hardware sysdm.cpl
Add new hardware Add/Remove Programs appwiz.cpl
Date/Time Properties timedate.cpl
Display Properties desk.cpl
FindFast findfast.cpl
Fonts Folder fonts
Internet Properties inetcpl.cpl
Joystick Properties joy.cpl
Keyboard Properties main.cpl keyboard
Microsoft Exchange mlcfg32.cpl
Microsoft Mail Post Office wgpocpl.cpl
Modem Properties modem.cpl
Mouse Properties main.cpl
Multimedia Properties mmsys.cpl
Network Properties netcpl.cpl (In Windows NT 4.0, Network properties is Ncpa.cpl, not Netcpl.cpl)
Password Properties password.cpl
PC Card main.cpl pc card
Power Management (Windows 95) main.cpl power
Power Management (Windows 98) powercfg.cpl
Printers Folder printers
Regional Settings intl.cpl
Scanners and Cameras sticpl.cpl
Sound Properties mmsys.cpl
Sounds System Properties sysdm.cpl

Examples:

Date/time applet, Time Zone tab:
Run("rundll32.exe","shell32.dll,Control_RunDLL TIMEDATE.CPL,@0,1")
Desktop applet, Screensaver tab:
Run("rundll32.exe","shell32.dll,Control_RunDLL DESK.CPL,@0,1")
Network applet, Protocols tab:
Run("rundll32.exe","shell32.dll,Control_RunDLL NCPA.CPL,@0,2")
Network applet, Adapters tab:
Run("rundll32.exe","shell32.dll,Control_RunDLL NCPA.CPL,@0,3")
System applet, Environment tab:
Run("rundll32.exe","shell32.dll,Control_RunDLL SYSDM.CPL,@0,2")
Sound
Run("rundll32.exe","shell32.dll,Control_RunDLL mmsys.cpl")
Joystick
Run("rundll32.exe","shell32.dll,Control_RunDLL joy.cpl")
Users Tool
Run("rundll32.exe","shell32.dll,Control_RunDLL inetcpl.cpl users")
Networks properties, Services tab
Run("rundll32.exe",shell32.dll,Control_RunDLL ncpa.cpl,,1")

Other tricks:

Format Disk
Run("rundll32.exe","shell32.dll,SHFormatDrive")

Copy Disk
Run("rundll32.exe","diskcopy.dll,DiskCopyRunDll")

Exit Windows
Run("RUNDLL32.EXE","USER.EXE,ExitWindows")

Restart Windows
Run("RUNDLL32.EXE","USER.EXE,ExitWindowsExec")

Logoff Windows 98 and run Explorer after relogon:
Run("RUNDLL32.EXE",SHELL32.DLL,SHExitWindowsEx 4")

Start "Add New Printer" wizard:
Run("RUNDLL32.EXE","SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter")

Show Windows 9*'s "System setting changed, do you want to reboot now?" dialog
Run("RUNDLL32.EXE","SHELL.DLL,RestartDialog")

Open a file with Windows' "Open as" dialog:
Run("RUNDLL32.EXE","SHELL32.DLL,OpenAs_RunDLL filename")

Swap your mouse to left handed:
Run("RUNDLL32.EXE","USER.EXE,SwapMouseButton"
Windows NT: Run("RUNDLL32.EXE","USER32.DLL,SwapMouseButton")

Start DialUp Network:
Run("RUNDLL32.EXE","RNAUI.DLL,RnaDial exact name of dialer entry")

Install ScreenSaver
Run("RUNDLL32.EXE","DESK.CPL,InstallScreenSaver filename.scr")

Display the Fonts Folder in Explorer view
Run("RUNDLL32.EXE","shell32.dll,SHHelpShortcuts_RunDLL FontsFolder")

Displays the Create New Shortcut dialog.
Run("RUNDLL32.EXE","shell32.dll,Control_RunDLL apwiz.cpl,NewLinkHere path")

Displays the Install/Uninstall tab selected
Run("RUNDLL32.EXE","shell32.dll,Control_RunDLL appwiz.cpl,,1")

Send the HTML file to the printer
Run("RUNDLL32.EXE","mshtml.dll,PrintHTML htmlfile.html")

Open the URL with an associated HTML browser.
Simple script:
Run("www.mediachance.com")

If you want to make the browser window TOP/TOPMOST use this code (Win2k/XP only):
Run("<System>\rundll32.exe","TOP <System>\shell32.dll,ShellExec_RunDLL www.mediachance.com")

..or this (Win2k/XP)
Run("<System>\rundll32.exe","<System>\url.dll,FileProtocolHandler www.mediachance.com")

..or this (Win9x)
Run("<Windows>\rundll32.exe","<System>\url.dll,FileProtocolHandler www.mediachance.com")

Create new email in an associated email client (with predefined address and subject)
The same as for URL path, but with email address.

Simple script:
Run("mailto:your@address.com")

If you want to make the email client window TOP/TOPMOST use this code (Win2k/XP only):
Run("<System>\rundll32.exe","TOP <System>\shell32.dll,ShellExec_RunDLL mailto:your@address.com?Subject="This is a test mail"")

..or this (Win2k/XP)
Run("<System>\rundll32.exe","<System>\url.dll,FileProtocolHandler mailto:your@address.com?Subject="This is a test mail"")

..or this (Win9x)
Run("<Windows>\rundll32.exe","<System>\url.dll,FileProtocolHandler mailto:your@address.com?Subject="This is a test mail"")

Displays Internet Properties, General Tab
Run("RUNDLL32.EXE","shell32.dll,Control_RunDLL inetcpl.cpl,,0")

Microsoft Exchange Profiles general property page
Run("RUNDLL32.EXE","shell32.dll,Control_RunDLL mlcfg32.cpl")

Microsoft Postoffice Workgroup Admin property page
Run("RUNDLL32.EXE","shell32.dll,Control_RunDLL wgpocpl.cpl")

Multimedia/Audio property page
Run("RUNDLL32.EXE","shell32.dll,Control_RunDLL mmsys.cpl,,0")